//
//  FRNavigationController.m
//  FastRunning
//
//  Created by YANG on 2018/4/16.
//  Copyright © 2018年 HUA. All rights reserved.
//

#import "FRNavigationController.h"

#import "FRLoginViewController.h"

#import "UIBarButtonItem+Extension.h"



@interface FRNavigationController ()

@end

@implementation FRNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self config];
}

/** 没有tabBar时候使用这个初始化方 */
+ (instancetype)setUpNavigationController{
    //判断用户是否登录
    if (YES) {

    }else{

    }
    return [[super alloc] initWithRootViewController:[[FRLoginViewController alloc] init]];;
}

/** 配置 */
- (void)config {
    self.navigationBar.backgroundColor = [UIColor clearColor];
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:18];
    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];

    self.navigationBar.titleTextAttributes = attrs;
    self.navigationBar.translucent = NO;
    self.navigationBar.barStyle = UIBarStyleBlackOpaque;
    [self.navigationBar setShadowImage:[UIImage new]];
}

/** 系统状态了颜色 */
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    //当Nav的子控制器个数大于0 修改子控制器的返回按钮
    if (self.viewControllers.count > 0) {

        UIBarButtonItem *backItem = [UIBarButtonItem itemWithLeftImage:[UIImage imageNamed:@"icon_leftreturn"] highImage:[UIImage imageNamed:@"icon_leftreturn"] target:self action:@selector(backVC)];
        viewController.navigationItem.leftBarButtonItem = backItem;
        viewController.hidesBottomBarWhenPushed = YES;
    }

    [super pushViewController:viewController animated:animated];
    self.navigationBarHidden = NO;
}

- (void)backVC {
    [self popViewControllerAnimated:YES];
}

@end
